//https://leetcode.cn/problems/merge-sorted-array/
//从后往前思考!
package dataStructure.Test088合并两个有序数组;


class Solution {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        //定义一个指向末尾的下标
        int last = m + n - 1;
        //让m和n指向相应的元素
        m = m - 1;
        n = n - 1;
        int p = 0;//该放入数组的元素值
        while (m >= 0 || n >= 0) {
            if (m == -1) {
                p = nums2[n--];
            } else if (n == -1) {
                p = nums1[m--];
            } else if (nums1[m] > nums2[n]) {
                p = nums1[m--];
            } else {
                p = nums2[n--];
            }
            nums1[last--] = p;
        }

    }

    public void haha(){
        System.out.println("123");
        int i;
        int b;
        int sadasdasdasd;
    }
}
